﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _023_什么是类_2
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Student stu1 = new Student(1,"橙子");
            Student stu2= new Student(2,"梨梨");
            Console.WriteLine(Student.Amount);
        }
    }

    //类就相当于数据结构
    class Student
    {

        //静态字段
        public static int Amount { get; set; }

        //静态构造器(只能构造静态成员)
        static Student()
        {
            Amount = 100;
        }


        public Student(int id, string name)
        {
            this.ID = id;
            this.Name = name;
            Student.Amount++;
        }

        public Student()
        {
            ID = 2;
            Name = "梨梨";
        }
        ~Student()
        {
            Amount--;
            Console.WriteLine(Student.Amount);
        }

        public int ID { get; set; }
        public string Name { get; set; }
        public void Report()
        {
            Console.WriteLine($"I am  #{ID} student,my name is {Name}");
        }

    }
}
